package com.wtpaint.zeuslib.db;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import com.wtpaint.lib.db.db.IZeusDbDao;
import com.wtpaint.lib.db.db.ZeusDbHelper;
import com.wtpaint.zeuslib.R;


public class DbActivity extends AppCompatActivity implements View.OnClickListener {

    IZeusDbDao<User> dao;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_db);
        findViewById(R.id.id_insert_btn).setOnClickListener(this);
        dao = ZeusDbHelper.getInstance().getZeusDbDao(User.class);
        ZeusDbHelper.getInstance().getZeusDbDao(OtherUser.class);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.id_insert_btn:
                User user = new User(1, "leo1", 28, "1");
                long result = dao.insert(user);
                if (-1 != result) {
                    Log.i("TAG", "插入成功");
                } else {
                    Log.i("TAG", "插入失败");
                }
                break;
        }
    }
}
